woogc/sequential_order_number/format
Name: woogc/sequential_order_number/format
Type: Filter
Arguments: (int) $order_number, (int) $order_id
The woogc/sequential_order_number/format
filter in WooCommerce allows you to customize the format of the order number generated for new orders within the WooCommerce Global Cart. This filter can be used to modify the default sequential order number by prepending or appending custom prefixes, suffixes, or any other modifications to suit your business needs.
Example Usage
The following code example demonstrates how to customize the order number format by adding a custom prefix to the order number:
add_filter ( 'woogc/sequential_order_number/format', 'custom_order_number_format', 10, 2 ); function custom_order_number_format ( $order_number, $order_id ) { $order_number = 'WHG-' . $order_number; return $order_number; }
The code should be placed inside a php file on wp-content/mu-plugins folder.
Description of the Code:
- Filter Hook:
woogc/sequential_order_number/format
is the filter hook that you use to modify the order number format before it’s returned and assigned to the order. - Parameters:
$order_number
: The original order number that would have been assigned.$order_id
: The ID of the order being created.
- Customization: In this example, the filter prepends the string ‘WHG-‘ to the order number, resulting in a customized order number like
WHG-12345
instead of the default sequential number like12345
.
Use Cases:
- Adding Prefix/Suffix: You can add a unique prefix (e.g., a store code, year, or order category) to the order number to make it more identifiable.
- Custom Order Formatting: The filter allows you to implement complex order number schemes (e.g., combining the current year, month, or specific product codes).
- Sequential Number Control: This method ensures that the numbering remains sequential but allows flexibility in format.
This filter is especially useful for businesses that need to integrate specific order numbering schemes for reporting, inventory management, or branding purposes in WooCommerce.